<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>chat room</title>
<script type='text/javascript' src='dwr/interface/ChatRoom.js'></script>
<script type='text/javascript' src='dwr/engine.js'></script>
<!--<script type='text/javascript' src='dwr/util.js'></script>-->
<link type="text/css" href="css/jquery-ui-1.8.6.custom.css" rel="stylesheet" />	
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.layout.min.js"></script>
<script>
	/**init start*/
	$(function() {
	    //exception
	    function errh(msg, exc) {
		    alert("Error message is: " + msg + " - Error Details: ");
				//+ dwr.util.toDescriptiveString(exc, 2));
	    }
	    //初始化好异常信息
	    dwr.engine.setErrorHandler(errh);
		//初始化好登陆dialog
		$( "#dialog-login" ).dialog({
			autoOpen: true,
			height: 300,
			width: 350,
			modal: true,
			resizable:false ,
			buttons: {
				Login: login
			},
			close: function() {
				//一直打开这个登陆dialog
				$( "#dialog-login" ).dialog( "open" );
		    }
		});
	});


	/*******AJAX 与后台交互   start   */
	//登陆操作,需要同步请求
	function login() {
		var username=$('#username').val();
		var password='password';
		if(username==''){
			alert('请输入用户名');
			$('#username').focus();
		}
		if(password==''){
			alert('请输入密码');
			$('#username').focus();
		}
		ChatRoom.login(username,password,function(data) {
			//登陆成功
			if (data == 'success') {
				window.location.replace('index.html');
			}else{
				alert('用户名或者密码错误，请重新输入');
			}
		});
	}
	/*******AJAX 与后台交互   end   */
</script>
</head>
<body>
<div id="dialog-login" title="login"> 
<form action="" id='loginForm'>
   用户名：<input type="text" name='username' id='username'><br />
</form>
</div> 
</body>
</html>